package edu.gyc.hiblog.controller;

import com.github.pagehelper.PageInfo;
import edu.gyc.hiblog.model.Post;
import edu.gyc.hiblog.service.PostService;
import edu.gyc.hiblog.vo.PostVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class IndexController extends BaseController {
    @Autowired
    PostService postService;

    @RequestMapping({"","/","/index"})
    public String index(@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,
                        Model model) {


        PageInfo<PostVo> postVos = postService.paging(pageNum);


        model.addAttribute("currentCategoryId",0);
        model.addAttribute("pageData", postVos);

        return "index";
    }
}
